home *** CD-ROM | disk | FTP | other *** search
- Path: news.cis.nctu.edu.tw!usenet
- From: terryt@mcs.com (Terry Trippany)
- Newsgroups: comp.lang.c++
- Subject: Re: Function body banned in .H file - Can I still inline?
- Date: 10 Jan 1996 17:45:46 GMT
- Organization: STR/Baxter Labs
- Message-ID: <4d0u0a$gc7@news.cis.nctu.edu.tw>
- References: <4d0ir0$68e@newsroom.hitc.com>
- NNTP-Posting-Host: @159.198.73.111
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-Newsreader: WinVN 0.99.7
-
- In article <4d0ir0$68e@newsroom.hitc.com>, cruegger@eos.hitc.com says...
- >
- >I am not permitted to put any function bodies into the .H file for a class.
- >Question:
- > I would still like to make the small accessor routines inline. What
- > is my recourse, if any?
- >
- >Thanks,
- >Chris
- >
- Hi Chris,
-
- If you want to make a function inline without putting the source in the
- header then you can use the inline keyword. BE AWARE that this is just a hint
- to the compiler and it may or may not treat it as inline depending on which
- compiler you use.
-
- eg:
- // file foo.hpp
-
- class Foo
- {
- void myFunc();
- }
-
- // file foo.cpp
-
- inline void Foo::myFunc() { ... }
-
- You could also specify the inline keyword in the declaration file if that's
- where you would like to put it.
-
-
- Either way some linkers can treat non-inlined functions that are declared as
- inline (ie. they don't inline the function for some reason) as if they had
- been declared static. Thus increasing code size if the compiler treats it
- this way as opposed to ignoring it altogether.
-
- Also, you should turn off inline functions for debugging.
-
- Later,
-
- Terry Trippany
- Strategic Technology Resources
- Chicago, IL.
-
- terryt@mcs.com
-
-